<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a="https://ajax4jsf.dev.java.net/ajax"
	xmlns:rich="http://richfaces.ajax4jsf.org/rich"
	xmlns:ctg="http://www.crotouristguide.com/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:component>
	<h:form id="registerForm">
		<a:region renderRegionOnly="true">
			<a:outputPanel ajaxRendered="true">
				<h:messages styleClass="message" globalOnly="true"
					errorClass="error" infoClass="info"></h:messages>
				<s:decorate id="imeDecoration" template="/templates/edit.xhtml">
					<ui:define name="label">
						<a:outputPanel ajaxRendered="true">
							<h:outputText value="#{messages['label.naziv']}"
								rendered="#{identity.hasRole('3')}" />
							<h:outputText value="#{messages['label.ime']}"
								rendered="#{identity.hasRole('2') or identity.hasRole('4')}" />
						</a:outputPanel>
					</ui:define>
					<h:inputText id="ime" styleClass="field" value="#{korisnik.ime}"
						required="true">
					</h:inputText>
				</s:decorate>
				<s:decorate id="prezimeDecoration" template="/templates/edit.xhtml"
					rendered="#{identity.hasRole('2') or identity.hasRole('4')}">
					<ui:define name="label">#{messages['label.prezime']}</ui:define>
					<h:inputText id="prezime" styleClass="field"
						value="#{korisnik.prezime}" required="true">
					</h:inputText>
				</s:decorate>
				<s:decorate id="maticniBrojDecoration"
					template="/templates/edit.xhtml"
					rendered="#{identity.hasRole('3')}">
					<ui:define name="label">#{messages['label.maticni_broj']}</ui:define>
					<h:inputText id="maticniBroj" required="true" styleClass="field"
						value="#{korisnik.maticniBroj}">
					</h:inputText>
				</s:decorate>
				<s:decorate id="adresaDecoration" template="/templates/edit.xhtml"
					rendered="#{identity.hasRole('3')}">
					<ui:define name="label">#{messages['label.adresa']}</ui:define>
					<h:inputText id="adresa" styleClass="field"
						value="#{korisnik.adresa}">
					</h:inputText>
				</s:decorate>
				<s:decorate id="kontaktImeDecoration"
					template="/templates/edit.xhtml"
					rendered="#{identity.hasRole('3')}">
					<ui:define name="label">#{messages['label.kontakt_ime']}</ui:define>
					<h:inputText id="kontaktIme" styleClass="field"
						value="#{korisnik.kontaktIme}">
					</h:inputText>
				</s:decorate>
				<s:decorate id="countryDecoration" template="/templates/edit.xhtml">
					<ui:define name="label">#{messages['label.country']}</ui:define>
					<h:selectOneMenu id="country" styleClass="field"
						value="#{korisnik.drzava}" required="true">
						<s:selectItems id="countries" value="#{drzave}" var="z"
							label="#{z.naziv}" noSelectionLabel="#{messages['label.choose']}" />
						<s:convertEntity></s:convertEntity>
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate id="placeDecoration" template="/templates/edit.xhtml">
					<ui:define name="label">#{messages['label.place']}</ui:define>
					<h:inputText id="place" styleClass="field"
						value="#{korisnik.mjesto}" required="true">
						<a:support event="onblur" reRender="placeDecoration"
							bypassUpdates="true" />
					</h:inputText>
				</s:decorate>
				<s:decorate id="zipCodeDecoration" template="/templates/edit.xhtml">
					<ui:define name="label">#{messages['label.zip.code']}</ui:define>
					<h:inputText id="zipCode" styleClass="field"
						value="#{korisnik.postanskiBroj}" required="true">
						<a:support event="onblur" reRender="zipCodeDecoration"
							bypassUpdates="true" />
					</h:inputText>
				</s:decorate>
				<s:decorate id="emailDecoration" template="/templates/edit.xhtml">
					<ui:define name="label">#{messages['label.email']}</ui:define>
					<h:inputText id="email" styleClass="field" required="true"
						value="#{korisnik.email}" />
				</s:decorate>
				<s:decorate id="phoneDecoration" template="/templates/edit.xhtml">
					<ui:define name="label">#{messages['label.phone']}</ui:define>
					<h:inputText id="phone" styleClass="field"
						value="#{korisnik.telefon}">
					</h:inputText>
				</s:decorate>
				<s:decorate id="mobilePhoneDecoration"
					template="/templates/edit.xhtml">
					<ui:define name="label">#{messages['label.mob_phone']}</ui:define>
					<h:inputText id="mobPhone" styleClass="field"
						value="#{korisnik.mobTelefon}">
					</h:inputText>
				</s:decorate>
				<br />
				<!--<h:panelGroup>
					<h:outputLabel value="#{messages['label.username']}" />
					<h:outputText id="username" styleClass="field"
						value="#{korisnik.username}">
					</h:outputText>
				</h:panelGroup>
				<br />
				<br />-->
				<s:decorate id="wwwDecoration" template="/templates/edit.xhtml"
					rendered="#{identity.hasRole('3')}">
					<ui:define name="label">#{messages['label.www']}</ui:define>
					<h:inputText id="www" styleClass="field" value="#{korisnik.www}" />
				</s:decorate>
				<s:div>
					<a:commandButton styleClass="submit"
						value="#{messages['label.update']}"
						action="#{profileAction.updateUserData}" />
				</s:div>

				<span class="note"><strong>#{messages['message.note.1']}</strong>#{messages['message.note.2']}
				<em>*</em> #{messages['message.note.3']}</span>
				<br />
			</a:outputPanel>
		</a:region>
	</h:form>

	<h:form id="logoForm" enctype="multipart/form-data">
		<s:decorate id="logoDecoration" template="/templates/edit.xhtml"
			rendered="#{identity.hasRole('3')}">
			<ui:define name="label">
				<h:outputText value="#{messages['label.logo']}" />
			</ui:define>
			<s:fileUpload id="logo" size="60" data="#{profileAction.logo}"
				contentType="#{profileAction.tipLoga}" accept="images/*"
				required="true" />
			<h:commandButton styleClass="submit"
				value="#{messages['label.osobine.input.button.addimage']}"
				action="#{profileAction.addLogo}">
			</h:commandButton>
		</s:decorate>
		<br />
		<h:panelGrid columns="2" rendered="#{korisnik.logo != null}">
			<h:outputText value="#{messsages['label.your_logo']}" />
			<s:graphicImage value="#{korisnik.logo}"
				alt="#{messages['label.image.alt']}">
				<s:transformImageSize width="200" height="120" maintainRatio="false" />
			</s:graphicImage>
		</h:panelGrid>

	</h:form>
</ui:component>

</html>